package moodish.comm;

import java.io.Serializable;

/**
 * Message Send from Server to a client.
 * 
 * Implements Serializable, ClientSideMessage
 */
public class MessageFromServer implements Serializable, ClientSideMessage {
	private static final long serialVersionUID = 5297241217165485925L;
	
	// Message Type, ClienteSideMessage.Type
	private Type type;
	
	// Sender & Payload
	private String sender;
	private String payload;

	
	/**
	 * Construtor 1: Receive the 
	 * Sender will be the server
	 * @param type Message Type
	 * @param payload Nickname 
	 */
	public MessageFromServer(Type type, String payload) {
		this.type = type;
		this.sender = ClientSideMessage.SERVER;
		this.payload = payload;
	}

	/**
	 * Construtor 2: Used for moodish messages
	 * @param type
	 * @param sender
	 * @param payload
	 */
	public MessageFromServer(Type type, String sender, String payload) {
		this.type = type;
		this.sender = sender;
		this.payload = payload;
	}
	
	/**
	 * Get the Message Type
	 * 
	 * @return ClientSideMessage type
	 */
	@Override
	public Type getType() {
		return type;
	}

	/**
	 * Get the Message Sender nickname
	 * 
	 * @return String sender
	 */
	@Override
	public String getSendersNickname() {
		return sender;
	}
	
	/**
	 * Get the message payload
	 * 
	 * @return String payload
	 */
	@Override
	public String getPayload() {
		return payload;
	}
}
